<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>简易计算器</title>
	<style>
		*{text-align: center;}
		.anniu{margin-left: 85px;}
	</style>
</head>
<body>
	<h1>简易计算器</h1>
	<p>第一个数字：<input type="text" id="num1"></p>
	<p>第二个数字：<input type="text" id="num2"></p>
	<hr>
	<div class="anniu">
		<input type="button" value="+" onclick="getResult('+')">&nbsp&nbsp&nbsp
		<input type="button" value="-" onclick="getResult('-')">&nbsp&nbsp&nbsp
		<input type="button" value="*" onclick="getResult('*')">&nbsp&nbsp&nbsp
		<input type="button" value="/" onclick="getResult('/')">
	</div>
	<p>计算结果：<span id="result">0</span></p>
</body>
</html>
<script>
function getResult (opa){
var num1=Number(document.getElementById('num1').value);
var num2=Number(document.getElementById('num2').value);
switch(opa){
	case '+':
	result.innerText=num1+num2;
	break;
	case '-':
	result.innerText=num1-num2;
	break;
	case '*':
	result.innerText=num1*num2;
	break;
    case '/':
	result.innerText=num1/num2;
	break;
}
}
</script>